<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>StringLen | AutoHotkey</title>
<meta name="description" content="The StringLen command retrieves the count of how many characters are in a string." />
<meta name="ahk:equiv-v2" content="commands/StrLen.htm" />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>StringLen</h1>
<p>获取字符串中包含的字符数量.</p>
<p class="warning"><strong>过时的:</strong> 不推荐在新脚本中使用此命令. 请使用 <a href="StrLen.htm">StrLen</a> 函数代替.</p>
<pre class="Syntax"><span class="func">StringLen</span>, OutputVar, InputVar</pre>

<h2 id="Parameters">参数</h2>
<dl>

  <dt>OutputVar</dt>
  <dd>用来存储字符串长度的变量名.</dd>

  <dt>InputVar</dt>
  <dd>需要统计长度的变量名. 不要把名称括在百分号中, 除非您希望使用变量的 <em>内容</em> 作为被解析的变量名.</dd>

</dl>

<h2 id="Remarks">备注</h2>
<p>如果 <var>InputVar</var> 是由 <a href="../misc/Clipboard.htm#ClipboardAll">ClipboardAll</a> 之前所赋值的变量, StringLen 将报告其总大小.</p>

<h2 id="Related">相关</h2>
<p><a href="StrLen.htm">StrLen()</a>, <a href="IfInString.htm">IfInString</a>, <a href="StringGetPos.htm">StringGetPos</a>, <a href="StringMid.htm">StringMid</a>, <a href="StringTrimLeft.htm">StringTrimLeft</a>, <a href="StringTrimLeft.htm">StringTrimRight</a>, <a href="StringLeft.htm">StringLeft</a>, <a href="StringLeft.htm">StringRight</a>, <a href="StringLower.htm">StringLower</a>, <a href="StringLower.htm">StringUpper</a>, <a href="StringReplace.htm">StringReplace</a></p>

<h2 id="Examples">示例</h2>
<div class="ex" id="ExBasic">
<p><a class="ex_number" href="#ExBasic"></a> 获取和报告字符串中包含的字符数量.</p>
<pre>StrValue := "The quick brown fox jumps over the lazy dog"
StringLen, Length, StrValue
MsgBox, The length of string is %Length%.</pre>
</div>

</body>
</html>